<template>
  <el-sub-menu v-if="menu.children?.length > 0" :index="ind + ''">
    <template #title>{{ menu.name }}</template>
    <NuxtLink
      alt=""
      v-for="(item, index) in menu.children"
      :to="
        item.attribute == 0
          ? '/articleType/' + ind + '-' + index + '.html'
          : item.attribute == 1
          ? '/singlePage/' + ind + '-' + index + '.html'
          : item.external_link
      "
      :target="item.open_type == 1 ? '_blank' : '_self'"
    >
      <el-menu-item :index="ind + '-' + index + '.html'">{{ item.name }}</el-menu-item></NuxtLink
    >
  </el-sub-menu>
  <NuxtLink
    alt=""
    v-else
    :to="
      ind == 0
        ? '/'
        : menu.attribute == 0
        ? '/articleType/' + ind + '.html'
        : menu.attribute == 1
        ? '/singlePage/' + ind + '.html'
        : menu.external_link
    "
    :target="menu.open_type == 1 ? '_blank' : '_self'"
    ><el-menu-item :index="ind + '' + '.html'">{{ menu.name }}</el-menu-item></NuxtLink
  >
</template>
<script setup lang="ts">
defineProps({
  menu: {
    type: Object as PropType<any>,
    required: true,
  },
  ind: {
    type: Number,
    required: true,
  },
});
</script>
